<?php
$this->breadcrumbs=array(
	'Page'=>array('/Cms/admin/page'),
    'Revision'=>array('/Cms/admin/pageRevision', 'page_id'=>$model->page_id),
	'Manage',
);

$script = "
jQuery('#content').delegate('.actions-column a.view', 'click', function(){
    var url = jQuery(this).attr('href');
    jQuery.fancybox({
        'titleShow'         : false,
        'height'            : '100%',
        'width'             : '100%',
        'autoScale'         : true,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'iframe',
        'href'              : url
    });
    return false;
});
jQuery('#target-site .popup-content').addClass('fix');
";
Yii::app()->clientScript->registerScript(__CLASS__.'#Preview', $script);
?>

<?php //echo CHtml::link('Refresh', '#', array('title'=>'Refresh', 'class'=>'reload-tab-content'));?>
<?php
$columns = array(
    array(
        'header'=>'Workflow',
        'name'=>'workflow_id',
        'value'=>'Yii::app()->controller->getWorkflowName($data->page_id, $data->workflow_id)',
    ),
    array(
        'header'=>'Revision',
        'name'=>'id',
        'htmlOptions'=>array('width'=>'3%', 'align'=>'center'),
    ),
    array(
        'name'=>'last_update',
        'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->last_update))',
        'htmlOptions'=>array(
            'class'=>'datetime-column'
        )
    ),
    array(
        'name'=>'updated_by',
        'value'=>'(is_object($data->updatedBy) ? $data->updatedBy->username : "")',
    ),
    array(
        'name'=>'creation_datetime',
        'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->creation_datetime))',
        'htmlOptions'=>array(
            'class'=>'datetime-column'
        )
    ),
    array(
        'name'=>'created_by',
        'value'=>'(is_object($data->createdBy) ? $data->createdBy->username : "")',
    ),
    array(
        'class'=>'CButtonColumn',
        'template'=>'{copy} {view} {go-to}',
        'viewButtonUrl'=>'is_object($data->page) && is_object($data->page->defaultUrl) ? "http://".trim($data->initialWorkflowUrl, "/")."/".trim($data->page->defaultUrl->url, "/")."/?preview=1&revision=".$data->id : "#"',
        'buttons'=>array(
            'go-to'=>array(
                'label'=>'Go to',
                'url'=>'is_object($data->page) && is_object($data->page->defaultUrl) ? "http://".trim(Yii::app()->controller->getWorkflowUrl($data->workflow_id), "/")."/".trim($data->page->defaultUrl->url, "/") : "#"',
                'imageUrl'=>Yii::app()->theme->baseUrl.'/images/link-go.png',
                'options'=>array('target'=>'_blank'),
            ),
            'copy'=>array(
                'label'=>'Copy',
                'imageUrl'=>Yii::app()->theme->baseUrl.'/images/copy-page.png',
                'url'=>'"#".$data->id',
                'options'=>array(
                    'class'=>'copy',
                ),
            ),
        ),
        'htmlOptions'=>array(
            'class'=>'actions-column',
        )
    ),
);
?>
<p>Below is list of workflows this page is visible. You can preview the page or click edit button to edit page content.<br/>
Edit you make in one workflow will not affect other workflow(s).</p>
<style type="text/css">
#fancybox-content .popup-content.fix .row {padding: 0;}
</style>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'page-revision-workflow-grid',
	'dataProvider'=>$model->search(true),
	'enableSorting'=>false,
	'columns'=>$columns,
));